/**
 * Copyright (C) 2012 Foxit Corporation.
 * All Rights Reserved.
 *
 * The following code is copyrighted and contains proprietary information and trade secrets of Foxit Corporation.
 * You can only redistribute files listed below to customers of your application, under a written SDK license agreement with Foxit.
 * You cannot distribute any part of the SDK to general public, even with a SDK license agreement.
 * Without SDK license agreement, you cannot redistribute anything.
 *
 * @file	fpdfpsi.h
 * @brief	Header file for the Pressure Sensitive Ink module.
 * @details	The module is based on the pressure sensitivity technology. <br>
 *			Users can use the methods in this module to:
 *			1. Connect to an external tablet and set the ARGB value and the diameter size of the brush.
 *			2. Initial a transparent canvas in the client zone to enable users to write or draw on it.
 *			3. Display the strokes with different states and pressure according to the user's drawing speed and pressure.
 *			4. Generate the PSI information to a PDF annotation and add the annotation to the page.
 * @note	If you want to purchase Foxit PDF SDK license and use ANY of the following functions, please
 *			request for enabling Pressure Sensitive Ink module explicitly.
 */
  
 /** 
 * @addtogroup FGSPDFPSI PDF PSI
 * @brief Methods in this module are included in fpdfpsi.h 
 */
/** @{*/

#ifndef __FGSPDFPSI__
#define __FGSPDFPSI__

#ifndef __FGSPDFBASE__
    #include "fpdfbase.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

/** 
 * @brief Structure for PSIProvider information. 
 */
typedef struct __PGSPDFPSIProvider {
    /** @brief The size of the data structure. It must be set to <I>sizeof</I>(::FPDF_SIGNATURE_HANDLER). */
    UInt32	size;
    
    /** @brief The user-supplied data.				*/
    void *	clientData;	

	/** @brief Invalidate the region of canvas.		*/
    void    (*invalidate)(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom);

	/** @brief Get the opacity value of opacity.	*/
    Float32	(*getOpacity)();

} PGSPDFPSIProvider;
  
/**
 * @defined __FGSPDFPSIHandler
 * @abstract FGS PDFPSIHandler ref
 */
typedef const struct __FGSPDFPSIHandler * FGSPDFPSIHandlerRef;

/**
 * @brief	Init the pressure sensitive ink environment.
 *
 * @param[in] psiProvider	Pointer to a ::PGSPDFPSIProvider Reference.
 * @param[in] bSimulate		Turn on/off the simulation of Pressure Sensitive Ink.	
 *
 * @return	Pointer to a <b>FGSPDFPSIHandlerRef</b> object that receives the Reference of PSI.
 *
 */
FGSPDFPSIHandlerRef	FGSPDFPSIInitEnvironment(PGSPDFPSIProvider* psiProvider, Boolean bSimulate);
        
/**
 * @brief	Destroy the pressure sensitive ink environment.
 *
 * @param[in] psiProvider	Reference to a PSI.
 *
 * @return	::kFGSErrorSuccess means set the information successfully.<br>
 *			For more definitions please see enum definitions <b>FGSErrorRet</b>.
 */
FGSErrorRet	FGSPDFPSIDestroyEnvironment(FGSPDFPSIHandlerRef hHandle);
        
/**
 * @brief	Init a PSI canvas.
 *
 * @param[in] hHandle		Reference to a PSI.
 * @param[in] width			The width of the PSI panel. This must be greater than 0.	
 * @param[in] height		The height of the PSI panel. This must be greater than 0.
 *
 * @return	::kFGSErrorSuccess means init the canvas successfully.<br>
 *			For more definitions please see enum definitions <b>FGSErrorRet</b>.
 *
 */
FGSErrorRet	FGSPDFPSIInitCanvas(FGSPDFPSIHandlerRef hHandle, SInt32 width, SInt32 height);
        
/**
 * @brief	Set the ink color.
 *
 * @param[in] hHandle		Reference to a PSI.
 * @param[in] color			The ink color. It's constructed by 0xrrggbb.
 *
 * @return	::kFGSErrorSuccess means set the ink color successfully.<br>
 *			For more definitions please see enum definitions <b>FGSErrorRet</b>.
 *
 */
FGSErrorRet	FGSPDFPSISetInkColor(FGSPDFPSIHandlerRef hHandle, UInt32 color);
        
/**
 * @brief	Set the ink diameter.
 *
 * @param[in] hHandle		Reference to a PSI.
 * @param[in] diameter		The ink diameter.
 *
 * @return	::kFGSErrorSuccess means set the ink diameter successfully.<br>
 *			For more definitions please see enum definitions <b>FGSErrorRet</b>.
 *
 */
FGSErrorRet	FGSPDFPSISetInkDiameter(FGSPDFPSIHandlerRef hHandle, SInt32 diameter);
 
/** 
 * @name FGSPDFPSI Enumeration Types
 */
/**@{*/
/**
 * @breif These definitions will be used in ::FGSPDFPSIAddPoint.
 */
enum {
    /** @ Point adding flags of LINETO */
    kFGSPSIPtLineTo			= 0x02,
    /** @ Point adding flags of MOVETO */
    kFGSPSIPtMoveTo         = 0x06,
    /** @ Point adding flags of ENDPATH */
    kFGSPSIPtEndPath        = 0x08
};
/** @brief Alias of enumeration for type of PSI adding points. */
typedef UInt32 FGSPDFPSIPointFlag;    
/**@}*/

/**
 * @brief	Add a pressure sensitive point to the environment.
 *
 * @param[in] hHandle		Reference to a PSI.
 * @param[in] x				The value of x-coordinate in the panel coordinate.
 * @param[in] y				The value of y-coordinate in the panel coordinate.
 * @param[in] pressure		The pressure of the current point between 0 to 1. 
 * @param[in] flag			The point flags. See macro definitions <b>::FGSPDFPSIPointFlag</b>
 *
 * @return	::kFGSErrorSuccess means add a point successfully.<br>
 *			For more definitions please see enum definitions <b>FGSErrorRet</b>.
 *
 */
FGSErrorRet	FGSPDFPSIAddPoint(FGSPDFPSIHandlerRef hHandle, Float32 x, Float32 y, Float32 pressure, FGSPDFPSIPointFlag flag);
        
/**
 * @brief	Render the pressure ink path to a device independent bitmap. 	
 *
 * @param[in] hHandle		Reference to a PSI.
 * @param[in] bitmapContext	A CGBitmapContext refernce, as the rendering device.
 * @param[in] xDes			The left pixel position of the area to render in the coordinate of destination.
 * @param[in] yDes			The top pixel position of the area to render in the coordinate of destination.
 * @param[in] nWidth		The width to render in the coordinate of destination.
 * @param[in] nHeight		The height to render in the coordinate of destination.
 * @param[in] xSrc			The left pixel position of the display area in the coordinate of canvas.	
 * @param[in] ySrc			The top pixel position of the display area in the coordinate of canvas.
 *
 * @return	::kFGSErrorSuccess means render the canvas to bitmap successfully.<br>
 *			For more definitions please see enum definitions <b>FGSErrorRet</b>.
 *
 */
FGSErrorRet	FGSPDFPSIRender(FGSPDFPSIHandlerRef hHandle, CGContextRef bitmapContext, SInt32 xDes, SInt32 yDes, SInt32 nWidth, SInt32 nHeight, SInt32 xSrc, SInt32 ySrc);
        
/**
 * @brief	Generate the PSI information to a PDF page.
 *
 * @param[in] hHandle		Reference to a PSI.
 * @param[in] page			Reference to a page.
 * @param[in] pageRect		The Page rect in the device coordinate.
 * @param[in] left			The left pixel position of the display area in the page coordinate.
 * @param[in] top			The top pixel position of the display area in the page coordinate.
 * @param[in] right			The right pixel position of the display area in the page coordinate.
 * @param[in] bottom		The bottom pixel position of the display area in the page coordinate.
 *
 * @return	::kFGSErrorSuccess means success.<br>
 *			For more definitions please see enum definitions <b>FGSErrorRet</b>.
 *
 */
FGSErrorRet	FGSPDFPSIGenerateAnnot(FGSPDFPSIHandlerRef hHandle, FGSPDFPageRef page, CGRect *pageRect, Float32 left, 
                                             Float32 top, Float32 right, Float32 bottom);

#ifdef __cplusplus
};
#endif

#endif // __FGSPDFPSI__
/**@}*/


